package kr.co.dayve.site.management.dao;

import kr.co.dayve.site.domain.Comment;
import kr.co.dayve.site.domain.CommunityBoard;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import java.util.List;

/**
 * 커멘트용 Dao 구현
 */
public class CommentDaoImpl extends SqlMapClientDaoSupport implements CommentDao {
    /**
     * 게시판 번호를 이용해 커멘트 리스트 가져오기
     *
     * @param comment
     * @return
     */
    public List getCommentListByBoardNo(Comment comment){
        return getSqlMapClientTemplate().queryForList("COMMENT.getCommentListByBoardNo", comment);
    }

    /**
     * 게시판 번호를 이용해 커멘트 총 갯수 구하기
     *
     * @param comment
     * @return
     */
    public String getTotalCountByBoardNo(Comment comment){
        return (String)getSqlMapClientTemplate().queryForObject("COMMENT.getTotalCountByBoardNo", comment);
    }

    /**
     *
     *
     * @param comment_no
     * @return
     */
    public Comment getCommentByNo(String comment_no){
        return (Comment)getSqlMapClientTemplate().queryForObject("COMMENT.getCommentByNo", comment_no);
    }

    public String writeComment(Comment comment){

        return Integer.toString(getSqlMapClientTemplate().update("COMMENT.writeComment", comment));
    }

    public String updateComment(Comment comment){
        return Integer.toString(getSqlMapClientTemplate().update("COMMENT.updateComment", comment));
    }

    public String deleteComment(Comment comment){
        return Integer.toString(getSqlMapClientTemplate().update("COMMENT.deleteComment", comment));
    }
}
